1 00:00:01,620 --> 00:00:04,860 Okay, Let's talk about the roadblocks data types in this video. 2 00:00:05,040 --> 00:00:09,450 There are several, but the ones I want to mention here are going to be the ones you'll use the most 3 00:00:09,450 --> 00:00:10,170 often. 4 00:00:10,350 --> 00:00:17,070 The first data type is vector three and vector three stores, three numbers that correspond to a vector 5 00:00:17,070 --> 00:00:18,240 in three space. 6 00:00:18,480 --> 00:00:19,680 What is a vector? 7 00:00:19,800 --> 00:00:25,560 Well, you can think of it as an arrow in three d space that has a direction basically where it's pointing 8 00:00:25,560 --> 00:00:29,700 and it has a magnitude, which is the length of the arrow and roadblocks. 9 00:00:29,700 --> 00:00:35,910 We can use vector threes as a way to define a point in 3D space or define a direction in three d space. 10 00:00:35,910 --> 00:00:41,010 The vector three data type holds three values that correspond to the X, Y, and Z coordinate. 11 00:00:41,400 --> 00:00:44,460 The next is much simpler, and that's color three. 12 00:00:44,730 --> 00:00:50,010 And this data type allows you to hold three numbers that represent the red, green and blue color values 13 00:00:50,010 --> 00:00:54,080 to make up over 16.8 million different colors. 14 00:00:54,090 --> 00:00:59,700 You'll use this data type all the time for changes in the color of parts, your eyes and a lot more. 15 00:01:00,510 --> 00:01:05,460 Instance, is another simple data type, and it's only used as a constructor that it has to create new 16 00:01:05,460 --> 00:01:11,220 instance objects like creating a new part, a new explosion, a new UI, whatever the case may be. 17 00:01:12,460 --> 00:01:17,110 The enum data type is short for enumeration or enumerated type. 18 00:01:17,320 --> 00:01:19,450 What the heck is an enumerated type? 19 00:01:19,570 --> 00:01:24,280 Well, enemies are used to define constants that represent a particular thing. 20 00:01:24,460 --> 00:01:28,720 So, for example, when you spawn a part in your game, it usually spawns as a rectangle. 21 00:01:28,750 --> 00:01:30,640 But what if I wanted to change the shape? 22 00:01:30,670 --> 00:01:33,550 Well, the part has a property that you can access. 23 00:01:34,630 --> 00:01:38,610 And it's called Shape, and it takes an enumerated type. 24 00:01:38,620 --> 00:01:43,780 And based on that, it changes the part shape to a constant defined within the enum. 25 00:01:44,110 --> 00:01:52,180 Like I have a ball, a block cylinder, and there's other extra ones like wedges in the model menu here 26 00:01:52,180 --> 00:01:53,740 for spawning parts. 27 00:01:54,110 --> 00:01:58,240 Another examples that you can use enemies to declare the types of things in your game, like how many 28 00:01:58,240 --> 00:02:03,420 different types of ores are in your game, like Diamond and Emerald and silver? 29 00:02:03,430 --> 00:02:09,460 Or what types of weapons are your game like Sword Hammer, whatever else the case may be. 30 00:02:09,490 --> 00:02:12,250 All it does is hold defined constants. 31 00:02:12,700 --> 00:02:17,610 The next data type is random, and this one will just simply use to get pseudo random numbers. 32 00:02:17,620 --> 00:02:20,860 This is better than using math at random because it's more unpredictable. 33 00:02:21,590 --> 00:02:23,420 And then lastly is see frame. 34 00:02:23,840 --> 00:02:29,300 And this is short for coordinate frame and it holds two vector three values, one that stands for a 35 00:02:29,300 --> 00:02:32,300 position and one that stands for the rotation. 36 00:02:32,330 --> 00:02:37,490 It also holds the look vector, right vector and up vector of the C frame. 37 00:02:37,490 --> 00:02:41,600 And those define the vectors, the direction that they are facing. 38 00:02:41,600 --> 00:02:47,600 So one's looking to the left, ones looking to the right, one's looking up, one's looking down, one 39 00:02:47,600 --> 00:02:48,740 looking forward. 40 00:02:48,740 --> 00:02:50,500 That's kind of the data it holds. 41 00:02:50,510 --> 00:02:53,300 We'll learn more about see frames in the next video. 42 00:02:54,070 --> 00:02:57,310 So let's go ahead and see an example of the vector three data type here. 43 00:02:57,850 --> 00:03:03,280 To see the vector three data type, I'll create a variable called position, and then I can use the 44 00:03:03,280 --> 00:03:09,340 vector three keyword and use the dot new function to create a new vector three object. 45 00:03:09,340 --> 00:03:15,580 And I can pass a value like five, five and five. 46 00:03:15,580 --> 00:03:16,600 Let's just do that. 47 00:03:17,230 --> 00:03:24,160 And now this returns to me a table that holds this position as well as a table that allows me to do 48 00:03:24,160 --> 00:03:26,260 things like add vectors together. 49 00:03:26,260 --> 00:03:31,360 So as we saw previously with using tables and meta tables, Roblox is doing the exact same thing here 50 00:03:31,360 --> 00:03:32,950 with their custom data type. 51 00:03:33,040 --> 00:03:38,260 And now using this position, I can take a part in my game. 52 00:03:38,260 --> 00:03:39,700 Let's click my game real quick. 53 00:03:40,590 --> 00:03:42,780 Maybe this big yellow part right here. 54 00:03:43,510 --> 00:03:46,570 On rename it to yellow part. 55 00:03:47,780 --> 00:03:49,640 And then I can go back to my script. 56 00:03:50,540 --> 00:03:57,020 And then I could do workspace, find my yellow part, and then I can set the position of this part to 57 00:03:57,020 --> 00:03:58,400 my new vector three. 58 00:03:59,930 --> 00:04:03,830 And I want to make sure that my part is also anchored so it doesn't fall. 59 00:04:04,340 --> 00:04:12,380 Now, if I run the game, this part should move from its position of 55 6.5 and -51 to a new position 60 00:04:12,380 --> 00:04:13,670 of five, five, five. 61 00:04:14,600 --> 00:04:15,610 Let's hit run. 62 00:04:18,000 --> 00:04:19,770 And you see, my part has disappeared. 63 00:04:19,770 --> 00:04:23,610 And now it is at the position of five, five, five. 64 00:04:25,090 --> 00:04:31,060 Now let's say I want to change the color of my part to, well, I can create another variable or actually, 65 00:04:31,060 --> 00:04:32,890 I won't create a variable at all. 66 00:04:32,980 --> 00:04:36,490 I'll just index the workspace again, get access to my part. 67 00:04:37,200 --> 00:04:40,290 And then I'll index the property color. 68 00:04:41,060 --> 00:04:43,850 And then I can set this color to a new color three value. 69 00:04:43,850 --> 00:04:45,950 So I'll use the keyword color three. 70 00:04:47,060 --> 00:04:49,460 And then there's several functions in here. 71 00:04:49,520 --> 00:04:54,260 We have new from our GB, HSV and hexadecimal. 72 00:04:54,710 --> 00:04:59,930 And for simplicity's sake, I'm going to use rugby, which gives you numbers to pick from starting at 73 00:04:59,930 --> 00:05:03,920 zero all the way up to 255 for red, green and blue. 74 00:05:05,200 --> 00:05:08,050 And they have this little cool button here that I can do. 75 00:05:09,220 --> 00:05:11,830 And pick my own color so I don't actually have to type the numbers in. 76 00:05:11,830 --> 00:05:16,480 So maybe I want it to be kind of like neon green, I guess. 77 00:05:17,830 --> 00:05:19,840 And it automatically puts the numbers. 78 00:05:20,570 --> 00:05:23,870 And now if I run my game, this part should change from yellow to green. 79 00:05:26,710 --> 00:05:27,370 Perfect. 80 00:05:31,210 --> 00:05:33,070 Now the next type is instance. 81 00:05:33,070 --> 00:05:34,360 And this one is very simple. 82 00:05:34,840 --> 00:05:36,460 If I use the keyword instance. 83 00:05:37,320 --> 00:05:39,230 And then access the new function. 84 00:05:39,270 --> 00:05:43,920 I can pass a class name, which is a string of the new instance I want to create. 85 00:05:43,920 --> 00:05:49,140 So maybe I want to create another part, a new part, and then I can actually pass another argument 86 00:05:49,140 --> 00:05:51,680 which sets the parent of the part. 87 00:05:51,690 --> 00:05:55,500 But usually you want to set the parent after you're done manipulating the part. 88 00:05:55,710 --> 00:06:00,870 Because if I set the parent immediately to the workspace, this part by default is unanchored, so it 89 00:06:00,870 --> 00:06:02,040 actually fall. 90 00:06:02,160 --> 00:06:09,720 Instead, I want to have my part be anchored first so I can store the return of this function in a variable. 91 00:06:09,720 --> 00:06:10,800 I'll call it new part. 92 00:06:12,130 --> 00:06:14,680 And then I'll set a new part to be anchored. 93 00:06:16,840 --> 00:06:19,180 And then I'll set the position of new part. 94 00:06:21,130 --> 00:06:27,640 And this new position will be a new vector three, and I'll set it to maybe 15, 15, 15. 95 00:06:29,200 --> 00:06:34,300 And then I can set the parent of my part to the workspace so that way we can actually see it in the 96 00:06:34,300 --> 00:06:34,720 game. 97 00:06:34,960 --> 00:06:36,490 Now, if I run the game again. 98 00:06:38,400 --> 00:06:40,140 We should see our new part somewhere. 99 00:06:40,170 --> 00:06:41,160 There it is. 100 00:06:42,030 --> 00:06:43,410 Here is our new part. 101 00:06:45,510 --> 00:06:49,000 Now let's go ahead and see the enumerator data type. 102 00:06:49,010 --> 00:06:55,040 So with my new part that I've created, maybe I want to change the shape of it so I can do new part 103 00:06:55,040 --> 00:06:56,450 and go to dot shape. 104 00:06:56,450 --> 00:07:00,380 And you can see it requires an enum of part type. 105 00:07:00,710 --> 00:07:04,370 So I can access these enemies by using the enum keyword. 106 00:07:04,400 --> 00:07:10,610 I can go to part type and in here it defines three different enemies that I can change it to. 107 00:07:10,610 --> 00:07:14,160 I can change to a cylinder, a ball or a block. 108 00:07:14,180 --> 00:07:16,010 So I'll just make it into a ball. 109 00:07:17,210 --> 00:07:21,110 And now if I run my game again, our new part should be a sphere. 110 00:07:21,900 --> 00:07:22,560 Here we go. 111 00:07:26,280 --> 00:07:28,830 And now the last data type I'm going to show here is random. 112 00:07:29,370 --> 00:07:30,600 And this one's very simple. 113 00:07:30,600 --> 00:07:35,010 Again, you do random create a new random data type. 114 00:07:35,580 --> 00:07:37,140 And I'll actually store it in a variable. 115 00:07:37,140 --> 00:07:39,210 I'll call it R and G. 116 00:07:39,810 --> 00:07:42,930 And using this variable, I can generate whatever random number I'd like. 117 00:07:42,930 --> 00:07:50,130 So maybe for my new part, I actually want to change the color to something random, Completely random. 118 00:07:50,490 --> 00:07:51,710 So I'll do color. 119 00:07:52,590 --> 00:07:54,750 I'll use the color three data type again. 120 00:07:55,740 --> 00:08:01,380 So I can pass the random data type and use a function in it that's called next integer. 121 00:08:03,920 --> 00:08:10,790 And I can pass a minimum number and a maximum number in this case, since we're going to be using actually 122 00:08:11,090 --> 00:08:16,460 from our GB instead of new, we're going to be limited to 0 to 255. 123 00:08:16,460 --> 00:08:22,550 So I'll put in zero 255 and it will pick a random number between it and then I can just copy this function. 124 00:08:25,150 --> 00:08:27,300 And do it three more times or two more times. 125 00:08:27,320 --> 00:08:28,510 We have a total of three. 126 00:08:28,900 --> 00:08:32,650 And now the color of this object should be completely random. 127 00:08:35,170 --> 00:08:36,220 See what color we got. 128 00:08:36,460 --> 00:08:41,910 We got a weird puke greenish black. 129 00:08:41,950 --> 00:08:45,850 But if I stop the test and run it again, we should get a completely different color. 130 00:08:45,880 --> 00:08:48,400 This time, we kind of got a reddish orange. 131 00:08:49,990 --> 00:08:51,640 Find the test and run it again. 132 00:08:53,450 --> 00:08:56,090 We get a nice purple color. 133 00:08:59,270 --> 00:08:59,780 All right. 134 00:08:59,780 --> 00:09:03,360 So that's pretty much the basics of these robots data types. 135 00:09:03,380 --> 00:09:07,730 I just wanted to expose you to these data types because you're going to be using them a lot. 136 00:09:08,090 --> 00:09:11,810 And in the next video, we're going to learn all about see frames. 137 00:09:11,900 --> 00:09:12,980 I'll see you there.